<template>
  <view class="content">
    <div style="height: 7vh;"></div>
    <div style="width: 84%;margin-left: 8%;">
      <image style="width: 100%;" mode="widthFix"
        src="https://28-1325662301.cos.ap-shanghai.myqcloud.com/Qingdao/001.png"></image>
    </div>
    <div style="height: 20px;"></div>
    <view class="content_box">
      <input type="number" v-model="account" style="
            width: 84%;
            margin-left: 8%;
            border: 2px solid #fff;
			box-sizing: border-box;
            height: 60px;
            font-size: 18px;
            border-radius: 12px;
			padding-left: 20rpx;
            color: #000000;
			background-color: #f3f4f6;
          " placeholder="账号" />
      <div style="height: 10px"></div>
      <input type="text" v-model="password" style="
            width: 84%;
            margin-left: 8%;
            border: 2px solid #fff;
			box-sizing: border-box;
            height: 60px;
			padding-left: 20rpx;
      font-size: 18px;
            border-radius: 12px;
			background-color: #f3f4f6;
            color: #000000;
          " placeholder="密码" />
      <div style="height: 10px"></div>
      <input type="text" v-model="teamCode" style="
            width: 84%;
            margin-left: 8%;
            border: 2px solid #fff;
			box-sizing: border-box;
            height: 60px;
			padding-left: 20rpx;
      font-size: 18px;
            border-radius: 12px;
			background-color: #f3f4f6;
            color: #000000;
          " placeholder="企业编码" />
      <div style="height: 20px"></div>
      <div style="
            color: #fff;
            width: 84%;
            margin-left: 8%;
           
            height: 60px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 40rpx;
            background: #000000;
          " @click="gotos">
        登陆
      </div>
    </view>
  </view>
</template>

<script>
import { logins } from "../../common/example";
export default {
  data() {
    return {
      base: '',
      // account:'17830000000',
      // password:'1234567',
      account: "",
      password: "",
      teamCode:'',
      userInfo: {
        nickname: "刘司机",
        account: "17830000000",
        role: "处理厂司机",
      },
      userInfos: {
        nickname: "刘牧主",
        account: "13999999999",
        role: "养殖场账号",
      },
      userInfoss: {
        nickname: "调度员",
        account: "17830000000",
        role: "调度员",
      },
      userInfossd: {
        nickname: "处理场操作员",
        account: "17830000000",
        role: "处理场操作员",
      },
    };
  },
  methods: {
    gotos() {
      if (!this.account || !this.password) {
        uni.showToast({
          title: "请输入完整后登录",
          icon: "none",
        });
      } else {
        uni.showLoading({
          title: '加载中'
        });
        logins({
          username: this.account,
          password: this.password,
          teamCode:this.teamCode
        }).then((res) => {
          console.log(res, 'res');

          if (res.data.code == 200) {
            uni.setStorageSync('pageIndent', res.data.user.remark);
            uni.hideLoading();
            uni.setStorageSync("token", res.data.token);
            uni.setStorageSync("userInfo", res.data.user);
            uni.setStorageSync("licenseNumber", res.data.licenseNumber);
            uni.setStorageSync("compLicenseNumber", res.data.licenseNumber);
            uni.setStorageSync('token', res.data.token);
            uni.showToast({
              title: "登录成功",
              icon: "success",
              mask: true,
            });
            if (res.data.user.remark == '处理厂操作员' || res.data.user.remark == '处理厂任务发布员') {
              setTimeout(() => {
                uni.redirectTo({ url: "/pagesPlant/index/feature" });
              }, 1000);
            } else {
              setTimeout(() => {
                uni.reLaunch({ url: "/pagesScreen/index/pagesCopyhome" });
              }, 1000);
            }


          } else {
            uni.showToast({
              title: res.data.msg,
              icon: "none",
            });
          }
        }).catch((e) => {
          console.log(e, 'eeeee');
          uni.hideLoading();
          uni.showToast({
            title: '请重试',
            icon: 'none'
          })
        });
      }
    },
  },
  onLoad() {
    console.log('1111');
    if (uni.getStorageSync("token")) {
      uni.reLaunch({ url: "/pagesScreen/index/pagesCopyhome" });
    }
  },
};
</script>

<style lang="scss">
.content {
  overflow: hidden;
  position: relative;
  height: 100vh;
  width: 100vw;
}

.logo {
  display: inline-block;
  width: 100%;
  position: absolute;
  z-index: -1;
}

.content_box {
  width: 100vw;
  height: 100vh;
  box-sizing: border-box;
}
</style>
